package image;


import com.agitar.lib.junit.AgitarTestCase;
import com.agitar.lib.mockingbird.Mockingbird;

import image.Image;

import java.awt.image.BufferedImage;

public class ImageAgitarTest extends AgitarTestCase {
    static Class TARGET_CLASS = Image.class;
    
    public void testConstructor() throws Throwable {
        BufferedImage image = (BufferedImage) Mockingbird.getProxyObject(BufferedImage.class);
        Mockingbird.enterTestMode();
        Image image2 = new Image(image);
        assertSame("image2.image", image, getPrivateField(image2, "image"));
    }
    
    public void testDrawThrowsNullPointerException() throws Throwable {
        Image image = new Image((BufferedImage) Mockingbird.getProxyObject(BufferedImage.class));
        Mockingbird.enterTestMode();
        try {
            image.draw(null, 100, 1000);
            fail("Expected NullPointerException to be thrown");
        } catch (NullPointerException ex) {
            assertNull("ex.getMessage()", ex.getMessage());
            assertThrownBy(Image.class, ex);
        }
    }
    
    public void testGetHeightThrowsNullPointerException() throws Throwable {
        Image image = new Image(null);
        try {
            image.getHeight();
            fail("Expected NullPointerException to be thrown");
        } catch (NullPointerException ex) {
            assertNull("ex.getMessage()", ex.getMessage());
            assertThrownBy(Image.class, ex);
            assertNull("image.image", getPrivateField(image, "image"));
        }
    }
    
    public void testGetWidthThrowsNullPointerException() throws Throwable {
        Image image = new Image(null);
        try {
            image.getWidth();
            fail("Expected NullPointerException to be thrown");
        } catch (NullPointerException ex) {
            assertNull("ex.getMessage()", ex.getMessage());
            assertThrownBy(Image.class, ex);
            assertNull("image.image", getPrivateField(image, "image"));
        }
    }
}

